/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openaecfm.spf.io;

import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.bidimap.DualHashBidiMap;

/**
 * @author Qiu Kuining
 */
public class SimpleAppDataManagerImpl implements IAppDataManager {

    private BidiMap bidi = new DualHashBidiMap();

    @Override
    public void save(String name, Object pojo) {
    	bidi.put(name, pojo);
    }

    @Override
    public Object getObject(String name) {
        if (!bidi.containsKey(name)) {
            throw new NotFoundException("Not found : " + name);
        }

        return bidi.get(name);
    }

    @Override
    public String getName(Object obj) {
        return (String)bidi.getKey(obj);
    }
}
